@echo off
echo Starting WVP GB28181 Video Platform with Fixed Configuration...

REM 清除可能影响的环境变量
set WVP_HOST=
set WVP_PORT=
set ZLM_HOST=
set ZLM_PORT=

REM 设置Java 8兼容的JVM参数
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParallelGC -XX:+UseParallelOldGC
set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
set JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=./logs/
set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless=true
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
set JAVA_OPTS=%JAVA_OPTS% -Duser.timezone=Asia/Shanghai
set JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true

REM 强制设置正确的配置参数
set JAVA_OPTS=%JAVA_OPTS% -DWVP_HOST=0.0.0.0
set JAVA_OPTS=%JAVA_OPTS% -DWVP_PORT=5060
set JAVA_OPTS=%JAVA_OPTS% -DZLM_HOST=127.0.0.1
set JAVA_OPTS=%JAVA_OPTS% -DZLM_PORT=80

REM 创建logs目录
if not exist logs mkdir logs

echo 检查Java版本...
java -version

echo 清理编译缓存...
mvn clean compile

echo 使用固定配置启动应用...
echo JVM Options: %JAVA_OPTS%

mvn spring-boot:run -Dspring-boot.run.jvmArguments="%JAVA_OPTS%" -Dspring.profiles.active=dev

pause
